#!/bin/bash

# Copy UERANSIM Configuration Files Script
# This script copies the configuration files to VM3 and VM4

set -e

# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

# Logging function
log() {
    echo -e "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')] $1${NC}"
}

info() {
    echo -e "${BLUE}$1${NC}"
}

echo
echo "=========================================="
echo "    Copy UERANSIM Configuration Files"
echo "=========================================="
echo

# Check if config files exist
if [ ! -f "config/gnb-vm3.yaml" ]; then
    echo "Error: config/gnb-vm3.yaml not found!"
    exit 1
fi

if [ ! -f "config/ue-vm4.yaml" ]; then
    echo "Error: config/ue-vm4.yaml not found!"
    exit 1
fi

log "Copying gNodeB configuration to VM3..."
scp config/gnb-vm3.yaml vm3:~/UERANSIM/config/gnb.yaml

log "Copying UE configuration to VM4..."
scp config/ue-vm4.yaml vm4:~/UERANSIM/config/ue.yaml

echo
log "Configuration files copied successfully!"
echo
echo "Next steps:"
echo "1. SSH to VM3 and start gNodeB:"
echo "   ssh vm3"
echo "   cd ~/UERANSIM"
echo "   ./build/nr-gnb -c config/gnb.yaml"
echo
echo "2. SSH to VM4 and start UE:"
echo "   ssh vm4"
echo "   cd ~/UERANSIM"
echo "   ./build/nr-ue -c config/ue.yaml"
echo
echo "3. Or run in background:"
echo "   nohup ./build/nr-gnb -c config/gnb.yaml > gnb.log 2>&1 &"
echo "   nohup ./build/nr-ue -c config/ue.yaml > ue.log 2>&1 &" 